package org.biogroovy.io;

import groovy.util.slurpersupport.NodeChild;

import java.io.IOException;
import java.io.InputStream;
import java.util.List;

/**
 * This interface describes the methods used by XmlSlurper to parse data.
 * @param <P> the POGO
 */
public interface ISlurper<P> {

	/**
	 * This method reads an input stream containing the XML for a protein or transcript.
	 * The XML is assumed to be the same format as that returned from the EUtils
	 * RESTful web service.
	 * @param inputStream  The input stream containing the XML record.
	 * @throws IOException if there is a problem reading the POGO.
	 */
	 P read(InputStream inputStream) throws IOException;

	 /**
	  * This method is responsible for parsing a single node and returning a model object.
	  * @param node the node to be parsed.
	  * @param model the model object.
	  */
	 void parse(P model, NodeChild node);

	 /**
	  * This method reads an input stream containing the XML for a list of objects.
	  * @param inputStream the input stream containing the REST response.
	  * @return a list of POGOs containing the results.
	  */
	  List<P> readList(InputStream inputStream) throws IOException;

}
